const { createClient } = require("webdav");
const config = require('config')
const webdav_path = `/remote.php/dav`;
const client = createClient(
    `${config.get('nextcloud.host')}${webdav_path}`,
    {username:process.env['NC_USER'], password:process.env['NC_USER_PASS']}
)
const nc = require('../utils/nc')

const version_path = ''

const testFileVersion = async()=>{
    let user = {id:process.env['NC_USER']},fileid=940
    let version_path = `/versions/${user.id}/versions/${fileid}`
    let results = await nc.getFileVersion(client,user,fileid)
    let contents = await client.getFileContents(`${version_path}/${results[0].basename}`,{ format: "text" });
    return contents
}

const tests = async()=>{
    return await testFileVersion()
}


tests().then((result) => {
        console.log(result)
        console.log('all tests finished');
    }
).catch((err) => {
    console.log(err)
})
